#include<iostream>
#include<algorithm>
#include<cstring>
#include<unordered_set>
#include<set>
#include<map>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10, M = 4e5 + 10;
int h[N], e[M], ne[M], idx;
int arr[5];
map<LL, int>mp;
int n, m;
void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx++;
}
int main()
{
	cin >> n >> m;
	memset(h, -1, sizeof(h));
	while (m--) {
		int a, b;
		cin >> a >> b;
		add(a, b);
		add(b, a);
	}
	LL res = 0;
	for (int i = 1; i <= n; i++) {
		memset(arr, 0, sizeof(arr));
		arr[0] = i;
		int cnt = 0;
		for (int j = h[i]; ~j; j = ne[j]) {
			int k = e[j];
			//cout << "k1===" << k << endl;
			//if (k == i)continue;
			arr[++cnt] = k;
		}
		//cout << "cnt==" << cnt << endl;
		if (cnt == 1)continue;
		sort(arr, arr + cnt);
		for (int j = 0; j < 3; j++) {
			//cout << "arr[]==" << arr[j] << endl;
		}
		for (int j = h[arr[1]]; ~j; j = ne[j]) {
			int k = e[j];
			//cout << "k2===" << k << endl;
			//if (k == i)continue;
			if (k == arr[2]) {
				//S.insert(arr[0] + arr[1] + arr[2]);
				LL ans = arr[0] + arr[1] + arr[2];
				if (!mp[ans]) {
					res++;
					mp[ans] = 1;
				}
			}
		}
	} 
	//cout << S.size() << endl;
	cout << res << endl;
	return 0;
}